var app = getApp();

//轮播图的数据图片
function getBannerData(block, position, type,key) {
  var _this = this;
  wx.request({
    url: app.globalData.httpApiCar + 'tGyImg/getImgsByParams',
    data: {
      block: block,
      position: position,
      type: type
    },
    header: {
      'content-type': 'application/json' // 默认值
    },
    success: function (res) {
      if (res.data.success) {
        _this.setData({
          [key]: res.data.data
        })
        
      }
    }
  })
}

//广告位
function getAdvertData(page,key) {
  var _this = this;
  wx.request({
    url: app.globalData.httpApiCar + 'tGyInformationDesk/all',
    data: {},
    header: {
      'content-type': 'application/json' // 默认值
    },
    success: function (res) {
      if (res.data.success) {
        if(key){
          _this.setData({
            [key]: res.data.data
          })
        }
      }
    }
  })
  // var arr = [
  //   '吃喝玩乐购，衣食住行需-一网打尽',
  //   '衣食住行需,吃喝玩乐购，一网打尽',
  //   '一网打尽,吃喝玩乐购，衣食住行需'
  // ]
  // return arr
}

//用户活动
function getActivityData() {
 return ''
}

//导航数据
function getIndexNavData() {

  var arr = [

    {
      id: 1,
      icon: app.globalData.imageUrl+'ic_people_looking_for_cars@2x.png',
      title: '顺风车',
      url:'../../pages/freeRideHome/freeRideHome'
    },
    {
      id: 2,
      icon: app.globalData.imageUrl+'ic_activity@2x.png',
      title: '活动',
      url: '../../pages/activity/activity'
    },
    {
      id: 3,
      icon: app.globalData.imageUrl+'ic_Industry_resources@2x.png',
      title: '行业资源',
      url: '../../pages/resources/resources'
    },
    {
      id: 4,
      icon: app.globalData.imageUrl+'ic_brand_marketers@2x.png',
      title: '品牌商家',
      url: '../../pages/brandBusiness/brandBusiness'
    }, 
    {
      id: 5,
      icon: app.globalData.imageUrl + 'ic_recruitment@2x.png',
      title: '求职招聘',
      url: '/pages/recruitHome/recruitHome'
    },
    {
      id: 6,
      icon: app.globalData.imageUrl + 'ic_house_lease@2x.png',
      title: '房屋租售',
      url: '../../pages/houseRenting/houseRenting'
    },
    {
      id: 7,
      icon: app.globalData.imageUrl + 'ic_blind_date@2x.png',
      title: '相亲',
      url: '/pages/blindHome/blindHome'
    },
    {
      id: 8,
      icon: app.globalData.imageUrl + 'ic_second_hand_spare@2x.png',
      title: '二手闲置',
      url: '../../pages/secondHand/secondHand'
    }
  ]

  return arr

}

// 房屋租售分类数据
function getHouseNavData(){
  var arr = [

    {
      id: 1,
      icon: app.globalData.imageUrl + 'ic_secondary@2x.png',
      title: '二手房',
      url: '../../pages/halfHouse/halfHouse'
    },
    {
      id: 2,
      icon: app.globalData.imageUrl + 'ic_bridal_chamber@2x.png',
      title: '新房',
      url: '../../pages/newHouse/newHouse'
    },
    {
      id: 3,
      icon: app.globalData.imageUrl + 'ic_rent_a_house@2x.png',
      title: '租房',
      url: '../../pages/rentHouse/rentHouse'
    },
    {
      id: 4,
      icon: app.globalData.imageUrl + 'ic_selling_house@2x.png',
      title: '卖房',
      url: '../../pages/changecity/changecity?title=卖房'
    },
    {
      id: 5,
      icon: app.globalData.imageUrl + 'ic_let_out@2x.png',
      title: '出租',
      url: '../../pages/changecity/changecity?title=出租'
    },
    {
      id: 6,
      icon: app.globalData.imageUrl + 'ic_decorate@2x.png',
      title: '装修',
      url: '../../pages/decorate/decorate'
    }
  ]

  return arr
}


//暴露接口
module.exports = {
  getBannerData: getBannerData,
  getAdvertData: getAdvertData,
  getIndexNavData: getIndexNavData,
  getActivityData: getActivityData,
  getHouseNavData: getHouseNavData
}